/*
 * Copyright 2007 National Bioinformatics Network
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package dgbgui.modeldocument;

import java.util.Set;

import junit.framework.TestCase;
import dgbgui.modeldocument.definition.ConceptTypeDefinition;

public class ModelDocumentTest extends TestCase {

    protected void setUp() throws Exception {
        m_queryA1 = new Query("A1", new ConceptTypeDefinition(1, "go_term"));
        m_queryA2 = new Query("A2", new ConceptTypeDefinition(1, "go_term"));
        m_queryB1 = new Query("B1", new ConceptTypeDefinition(1, "go_term"));
        m_queryB2 = new Query("B2", new ConceptTypeDefinition(1, "go_term"));

        ModelDocument.getInstance().clear();
    }

    protected void tearDown() throws Exception {
        ModelDocument.getInstance().clear();
    }

    public void testAddReplaceRemove() throws Exception {

        ModelDocument doc = ModelDocument.getInstance();
        // Add
        doc.add(m_queryA1);
        assertTrue(doc.contains(m_queryA1));
        doc.add(m_queryB1);
        assertTrue(doc.contains(m_queryB1));
        // Replace
        doc.replace(m_queryA1, m_queryA2);
        assertTrue(doc.contains(m_queryA2));
        assertFalse(doc.contains(m_queryA1));
        assertTrue(doc.size() == 2);
        // Delete
        doc.remove(m_queryA2);
        assertFalse(doc.contains(m_queryA2));
        doc.remove(m_queryB1);
        assertTrue(doc.size() == 0);

    }

    Query m_queryA1, m_queryA2;

    Query m_queryB1, m_queryB2;

    Set<String> m_attribNamesA;

    Set<String> m_attribNamesB;

}
